package com.ie.service.before;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ie.common.http.ResponseResult;
import com.ie.entity.before.FocusEntity;
import com.ie.mapper.before.FocusMapper;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * @author
 */
@Service
public class FocusServiceImpl extends ServiceImpl<FocusMapper, FocusEntity> implements FocusService{


    @Override
    public ResponseResult<Map<String, Object>> addFocus(FocusEntity focusEntity) {
        Long count = lambdaQuery().eq(FocusEntity::getBusertableId,focusEntity.getBusertableId())
                .eq(FocusEntity::getGoodstableId,focusEntity.getGoodstableId())
                .count();
        if (count > 0){
            return ResponseResult.getMessageResult(null,"A001");
        } else {
            focusEntity.setFocustime(new Date());
            if(save(focusEntity)){
                return ResponseResult.getMessageResult(null,"A002");
            }
            return ResponseResult.getMessageResult(null,"A003");
        }
    }


}